﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/h-ui.admin/skin/default/skin.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/h-ui.admin/css/style.css" />
<title>模块菜单</title>
</head>
<body>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray"> <span class="l"> 
	<input type="hidden" value="${pid}" name="parentCode" id="parentCode"/>
	<a class="btn btn-primary radius" href="javascript:window.history.go(-1)" >返回</a>
	<a class="btn btn-primary radius" href="javascript:;" onclick="module_add('添加模块','${pageContext.request.contextPath}/back/module/admin-add-module.htm?parentCode='+${pid},'700','500')"> 添加</a>
	<!-- <a class="btn btn-primary radius" onclick="module_del();" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 删除模块</a> --></span> </div>
	<table class="table table-border table-bordered table-hover table-bg">
		<thead>
			<!-- <tr>
				<th scope="col" colspan="6">角色管理</th>
			</tr> -->
			<tr class="text-c">
				<th width="25"><input type="checkbox" value="" name=""></th>
				<th width="80">编号</th>
				<th width="200">名称</th>
				<th width="250">链接</th>
				<th width="200">子模块</th>
				<th width="70">操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${modules}" var="module" varStatus="stat">
			<tr class="text-c">
				<td><input type="checkbox" id="box_${stat.index}" value="${module.id}" name="checkModule"></td>
				<td>${module.id}</td>
				<td>${module.name}</td>
				<td>${module.url}</td>
				<td><a class="btn btn-primary radius" href="${pageContext.request.contextPath}/back/permission/getModulesByParent.htm?id=${module.id}" > 查看下级</a></td>
				<td class="f-14">
				<a title="编辑" href="javascript:;" onclick="admin_update_module('模块编辑','${pageContext.request.contextPath}/back/module/updateModule.htm?id=${module.id}&pid=${pid}','700','500')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> 
				<a title="删除" href="javascript:;" onclick="module_del('${module.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
</div>
<!--_footer 作为公共模版分离出去-->
<script src="${pageContext.request.contextPath}/static/js/jquery-1.11.0.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath}/static/h-ui/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/h-ui/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath}/static/h-ui/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript">
/*添加模块*/
function module_add(title,url,w,h){
	layer_show(title,url,w,h); 
}


function roleAddUser(){
	var checkedRole = $("input[id^=box_]:checked");
	if(checkedRole.length != 1){
		layer.msg('请选择一条数据!',{icon:5,time:1000});	
		return;
	}
	var roleId = checkedRole.val();
	window.location.href="${pageContext.request.contextPath}/back/role/role-add-user.htm?roleId="+roleId;
}


/*编辑模块*/
function admin_update_module(title,url,w,h){
	layer_show(title,url,w,h);
}
/*删除模块*/
function module_del(id){	
 	layer.confirm('模块删除须谨慎，确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '${pageContext.request.contextPath}/back/module/module_del.htm?id='+id,
			dataType: 'json',
			success: function(data){
				//$(obj).parents("tr").remove();
				if(data.code==0){
					layer.msg('已删除!',{icon:1,time:1000});
					setTimeout(function () {
						//window.parent.location.href="${pageContext.request.contextPath}/back/permission/admin-permission.htm";
						var parentCode = $("#parentCode").val();
						parent.refreshDtree(parentCode);
						parent.refreshRight(parentCode);
	                }, 1500);
				}else{
					layer.msg('删除失败!',{icon:5,time:1000});
				}				
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	}); 
}
</script>
</body>
</html>